package com.pig4cloud.pigx.strategy.websocket.app.handler;

import com.pig4cloud.pigx.common.websocket.handler.JsonMessageHandler;
import com.pig4cloud.pigx.strategy.websocket.app.manager.WsManager;
import com.pig4cloud.pigx.strategy.websocket.app.message.UnSubscribeMessage;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.socket.WebSocketSession;

/**
 * @author 13596
 */
@Slf4j
@Component
@AllArgsConstructor
public class UnSubscribeHandler implements JsonMessageHandler<UnSubscribeMessage> {

    private WsManager wsManager;

    @Override
    public void handle(WebSocketSession session, UnSubscribeMessage message) {
        wsManager.unsubscribe(session, message);
    }

    @Override
    public String type() {
        return UnSubscribeMessage.TYPE;
    }

    @Override
    public Class<UnSubscribeMessage> getMessageClass() {
        return UnSubscribeMessage.class;
    }

}
